package com.hc.service.impl;

import com.hc.bean.Order;
import com.hc.bean.OrderDetail;
import com.hc.bean.Pager;
import com.hc.dao.OrderDao;
import com.hc.service.OrderService;
import org.apache.ibatis.annotations.Insert;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class OrderServiceImpl implements OrderService {
    @Resource
    private OrderDao orderDao;

    @Override
    public Boolean addOrder(Order order) {
        if(orderDao.addOrder(order)>0)
            return true;
        return false;
    }

    @Override
    public Boolean addOrderDetail(OrderDetail orderdetail) {
        if(orderDao.addOrderDetail(orderdetail)>0)
            return true;
        return false;
    }

    @Override
    public List<Order> getOrderByUid(Pager pager, Integer userId) {
        return orderDao.getOrderByUid(pager,userId);
    }

    @Override
    public List<Order> getOrderCountByUid(int userId) {
        return orderDao.getOrderCountByUid(userId);
    }
}
